<template>
  <div class="loginContainer">
    <img class='code_img' v-if='url' src="imgHost+url" @click='previewImg' />
  </div>
</template>

<script type="text/javascript">
import tabBar from '../tab_bar/tab_bar.vue';
import { mapState } from 'vuex'
export default {
  components:{
      tabBar
  },
  data() {
    return {
      url:''
    }
  },
  onShow() {
    if(!this.url){
      this.getCode()
    }
  },
  methods:{
    getCode(){
      this.$http.post({
          url:'/common/getWxAcode',
          data:{
            scene:wx.getStorageSync('tenancyId')
          }
      }).then(res=>{
        if(res.s==0){
          this.url = res.i.Data;
        }
      }).catch(e=>{
        console.error('获取失败',e)
      })
    },
    previewImg(index,urls){
        var that = this;
        wx.previewImage({
            current:that.imgHost+that.url,
            urls:[that.imgHost+that.url]
        });
    }
  },
  computed:{
    ...mapState(['userInfo','imgHost']),
  }
}
</script>

<style lang='less'>
  page{
    height: 100%;
    background:#eef7fd;
  }
  .loginContainer{
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    .code_img{
      width:80%;
    }
  }
</style>

